﻿function AzureOnlineBlobContainer($initialInfo) {

    var self = this;

    self.name = ko.observable('');

    self.url = ko.observable('');

    self.etag = ko.observable('');

    self.lastModified = ko.observable('');
    
    self.metadata = ko.observableArray([]);
    
    self.setInfo = function ($info) {
        self.name($info.find('Name').text());
        self.url($info.find('Url').text());
        self.etag($info.find('Etag').text());
        
        self.lastModified($info.find('Last-Modified').text());
        
        var $meta = $info.find('Metadata').children();
        var meta = [];
        for (var i = 0; i < $meta.length; i++) {
            var $metaItem = $($meta[i]);
            var name = $metaItem.prop('tagName');
            var value = $metaItem.text();
            meta.push({
                name: name,
                value: value
            });
        }

        self.metadata(meta);
    };

    if ($initialInfo) {
        self.setInfo($initialInfo);
    }
}